VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Object = "{B3FB64BF-91F9-11D7-A482-0008A14158BC}#2.22#0"; "ITGControls.ocx"
Begin VB.Form frmApprovalStockDetails 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Sales Order Approval (Stock Availability Details)"
   ClientHeight    =   4065
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   8325
   ControlBox      =   0   'False
   BeginProperty Font 
      Name            =   "Tahoma"
      Size            =   8.25
      Charset         =   0
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   Icon            =   "frmApprovalStockDetails.frx":0000
   KeyPreview      =   -1  'True
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   4065
   ScaleWidth      =   8325
   StartUpPosition =   2  'CenterScreen
   Begin VB.Frame Frame1 
      Height          =   3960
      Left            =   60
      TabIndex        =   2
      Top             =   60
      Width           =   8235
      Begin ITGControls.ITGTextBox txtCode 
         Height          =   285
         Left            =   240
         TabIndex        =   3
         Top             =   600
         Width           =   2610
         _ExtentX        =   4604
         _ExtentY        =   503
         SendKeysTab     =   -1  'True
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         AllCaps         =   -1  'True
         Mandatory       =   -1  'True
         Locked          =   -1  'True
         Label           =   "Customer"
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         LabelWidth      =   1000
         TextBoxWidth    =   1550
      End
      Begin ITGControls.ITGTextBox txtName 
         Height          =   285
         Left            =   2820
         TabIndex        =   4
         Top             =   600
         Width           =   5370
         _ExtentX        =   9472
         _ExtentY        =   503
         SendKeysTab     =   -1  'True
         BackColor       =   14737632
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Locked          =   -1  'True
         Label           =   "ITGtext"
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         LabelWidth      =   0
         TextBoxWidth    =   5310
      End
      Begin ITGControls.ITGTextBox txtSONo 
         Height          =   285
         Left            =   240
         TabIndex        =   0
         Top             =   300
         Width           =   2610
         _ExtentX        =   4604
         _ExtentY        =   503
         SendKeysTab     =   -1  'True
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         AllCaps         =   -1  'True
         Mandatory       =   -1  'True
         Locked          =   -1  'True
         Label           =   "Order No."
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         LabelWidth      =   1000
         TextBoxWidth    =   1550
      End
      Begin MSComctlLib.ListView lvwList 
         Height          =   2130
         Left            =   120
         TabIndex        =   1
         Top             =   1050
         Width           =   8040
         _ExtentX        =   14182
         _ExtentY        =   3757
         View            =   3
         Sorted          =   -1  'True
         LabelWrap       =   -1  'True
         HideSelection   =   -1  'True
         Checkboxes      =   -1  'True
         FlatScrollBar   =   -1  'True
         FullRowSelect   =   -1  'True
         GridLines       =   -1  'True
         HotTracking     =   -1  'True
         _Version        =   393217
         ForeColor       =   -2147483640
         BackColor       =   -2147483643
         BorderStyle     =   1
         Appearance      =   0
         NumItems        =   8
         BeginProperty ColumnHeader(1) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
            Text            =   "Product ID"
            Object.Width           =   2646
         EndProperty
         BeginProperty ColumnHeader(2) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
            SubItemIndex    =   1
            Text            =   "Description"
            Object.Width           =   3528
         EndProperty
         BeginProperty ColumnHeader(3) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
            SubItemIndex    =   2
            Text            =   "Unit"
            Object.Width           =   1235
         EndProperty
         BeginProperty ColumnHeader(4) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
            Alignment       =   1
            SubItemIndex    =   3
            Text            =   "Quantity"
            Object.Width           =   1587
         EndProperty
         BeginProperty ColumnHeader(5) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
            SubItemIndex    =   4
            Text            =   "Reference Identity"
            Object.Width           =   0
         EndProperty
         BeginProperty ColumnHeader(6) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
            SubItemIndex    =   5
            Text            =   "Status"
            Object.Width           =   1764
         EndProperty
         BeginProperty ColumnHeader(7) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
            SubItemIndex    =   6
            Text            =   "DR Ready"
            Object.Width           =   1764
         EndProperty
         BeginProperty ColumnHeader(8) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
            SubItemIndex    =   7
            Text            =   "Ref. WRR"
            Object.Width           =   1852
         EndProperty
      End
      Begin ITGControls.ITGCommandButton cmdCancel 
         Height          =   660
         Left            =   6870
         TabIndex        =   5
         Top             =   3240
         Width           =   1290
         _ExtentX        =   2275
         _ExtentY        =   1164
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Caption         =   "&Cancel"
      End
      Begin ITGControls.ITGCommandButton cmdApprove 
         Height          =   660
         Left            =   5595
         TabIndex        =   6
         Top             =   3240
         Width           =   1290
         _ExtentX        =   2275
         _ExtentY        =   1164
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Caption         =   "&Approve"
      End
      Begin VB.Line Line1 
         X1              =   120
         X2              =   8145
         Y1              =   990
         Y2              =   990
      End
   End
End
Attribute VB_Name = "frmApprovalStockDetails"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private mSONo As String
Private mCode As String

Private Sub cmdApprove_Click()
    With lvwList
        For i = 1 To .ListItems.Count
            If .ListItems(i).Checked = True Then
                cn.Execute "UPDATE SO_T SET lDRReady = 1 WHERE cSONo = '" & mSONo & "' AND nIdentity = " & CLng(.ListItems(i).SubItems(4)) & " AND cCompanyID = '" & COID & "'"
                If Trim(.ListItems(i).SubItems(6)) = "No" Then
                    UpdateLogFile "Stock Approval (Item Identity)", Trim(.ListItems(i).SubItems(4)), "Stock Force Approved"
                End If
            Else
                If Trim(.ListItems(i).SubItems(7)) = "" Then
                    cn.Execute "UPDATE SO_T SET lDRReady = 0 WHERE cSONo = '" & mSONo & "' AND nIdentity = " & CLng(.ListItems(i).SubItems(4)) & " AND cCompanyID = '" & COID & "'"
                    If Trim(.ListItems(i).SubItems(6)) = "Yes" Then
                        UpdateLogFile "Stock Approval Cancelled(II)", Trim(.ListItems(i).SubItems(4)), "Approval Cancelled"
                    End If
                End If
            End If
        Next i
    End With
    
    mApprovalAction = A_Approve
    Unload Me
End Sub

Private Sub cmdCancel_Click()
    mApprovalAction = A_Cancel
    Unload Me
End Sub

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = vbKeyEscape Then
        mApprovalAction = A_Cancel
        Unload Me
    End If
End Sub

Private Sub Form_Load()
    mSONo = Trim(mInboxRef)
    mCode = Trim(mInboxRefCode)
    
    txtSONo = mSONo
    txtCode = mCode
    
    sSQL = "SELECT * FROM SO_T WHERE cSONo = '" & mSONo & "' AND cCompanyID = '" & COID & "'"
    Set rs = New Recordset
    rs.Open sSQL, cn, adOpenForwardOnly, adLockOptimistic
    
    Do Until rs.EOF
        Set itmX = lvwList.ListItems.Add(, , Trim(rs!cItemNo) & "")
        itmX.SubItems(1) = Trim(rs!cDesc) & ""
        itmX.SubItems(2) = Trim(rs!cUnit) & ""
        itmX.SubItems(3) = Format(rs!nQty, "###,##0.#0") & ""
        itmX.SubItems(4) = rs!nIdentity & ""
        itmX.SubItems(5) = Trim(rs!cStatus) & ""
        itmX.SubItems(6) = IIf((rs!lDRReady), "Yes", "No") & ""
        itmX.SubItems(7) = Trim(rs!cRefNo) & ""
        rs.MoveNext
    Loop
    
    Set rs = Nothing
    
    With lvwList
        For i = 1 To .ListItems.Count
            If Trim(.ListItems(i).SubItems(6)) = "Yes" Then .ListItems.Item(i).Checked = True
        Next i
    End With
End Sub

Private Sub Form_Unload(Cancel As Integer)
    Set frmApprovalStockDetails = Nothing
End Sub

Private Sub lvwList_ColumnClick(ByVal ColumnHeader As MSComctlLib.ColumnHeader)
    lvwList.Sorted = True
    lvwList.SortKey = ColumnHeader.Index - 1
End Sub

Private Sub lvwList_ItemCheck(ByVal Item As MSComctlLib.ListItem)
    If lvwList.ListItems.Count = 0 Then Exit Sub
    If Trim(Item.SubItems(7)) <> "" Then
        If Trim(Item.SubItems(6)) = "Yes" Then Item.Checked = True
    End If
End Sub

Private Sub lvwList_KeyPress(KeyAscii As Integer)
    If lvwList.ListItems.Count = 0 Then Exit Sub
    If KeyAscii = 13 Then
        If lvwList.SelectedItem.Checked = True Then
            lvwList.SelectedItem.Checked = False
        Else: lvwList.SelectedItem.Checked = True
        End If
    End If
    
    If Trim(lvwList.SelectedItem.SubItems(7)) <> "" Then
        If Trim(lvwList.SelectedItem.SubItems(6)) = "Yes" Then lvwList.SelectedItem.Checked = True
    End If
End Sub

Private Sub txtCode_Change()
    txtName = ""
    txtName = GetValueFrTable("cName", "CLIENT_CUSTOMER", "cCode = '" & Trim(txtCode) & "'")
End Sub
